<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>创建新色卡</title>
        <script type="text/javascript" src="index.php?act=jslang"></script>
        <script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
        <script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
        <script language="javascript" type="text/javascript" src="{lib file=ajaxfileupload.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
        <script language="JavaScript" type="text/javascript" src="{res file=js/lan.js}"></script>
      
        <link href="template/style/css/style.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" charset="utf-8" src="{lib file="swfupload/swfupload.js"}"></script>
<script type="text/javascript" charset="utf-8" src="{lib file="swfupload/js/handlers.js"}"></script>
  <link type="text/css" rel="stylesheet" href="{lib file="swfupload/css/default.css"}"/>

        <style>
            label.error {color:red;}
			input {
				vertical-align: -5px;_vertical-align: -1px;margin-right: 5px
			}
        </style>
        <script type="text/javascript">
$(function(){
	$('#color_form').validate({
    	onkeyup : false,
 		onfocusout : false,
		rules : {
			update_time: {
				required: true
			},
			fabric_shop_id: {
				required: true
			},
			item: {
				required: true
			},
			file_required:{
				required: function(){
						return !$("a:parent img").size() && !$("[type='file'][name~='file'][value!='']").size();
				}
			}
		},
		messages : {
			update_time: {
				required: '请选择更新日期'
			},
			fabric_shop_id: {
				required: '请选择布行/档口'
			},
			item: {
				required: '请输入品名/货号'
			},
			file_required:{
				required: '请选择图片'
			}
		}
	});
});
</script>
        <script language="JavaScript">
	function check_fi(){
		//alert($("#fabric_shop_id option:selected").val());
		//alert($("#item").val());
		var fabric_shop_id = $("#fabric_shop_id option:selected").val();
		var item = $("#item").val();
		$.getJSON( '{$site_url}/index.php?app=colorcard&act=check_fi&fsi='+fabric_shop_id+'&item='+item,function(json){
			if(json.done){
				if(json.retval!=0){
					alert("该布行/档口的品名/货号已存在！请重新输入！");
					$("#item").val('');
				}
			}else{
                alert(json.msg);
            }
        });
	}
	
function add_file(obj) {
	var parent = obj.parentNode;
	var span = document.createElement('span');
	span.innerHTML = '<input type="file" name="files[]" class="input-2" hidefocus="true" /><a href="" onclick="remove_file(this);return false;" class="pic_del">移除</a><br /><br />';
	parent.insertBefore(span, obj);
}

function remove_file(obj) {
	var parent = obj.parentNode.parentNode;
	parent.removeChild(obj.parentNode);
}
	</script>
    
    <script type="text/javascript">
var GOODS_SWFU;
$(function(){
    GOODS_SWFU = new SWFUpload({
        upload_url: "index.php?app=comupload&act=newupload&belongs=86&id=11111333",
        flash_url: '{lib file="swfupload/swfupload.swf"}',
        post_params: {
            "ECM_ID": "{$smarty.cookies.ECM_ID}",
			"PHPSESSID":"{$phpsision}",
            "HTTP_USER_AGENT":"{$smarty.server.HTTP_USER_AGENT}",
            'ajax': 1
        },
        file_size_limit: "5 MB",
        file_types: "*.gif;*.jpg;*.jpeg;*.png",
        custom_settings: {
            upload_target: "goods_upload_progress",
            if_multirow: 1
        },

        // Button Settings
        button_image_url: '{lib file="swfupload/images/SmallSpyGlassWithTransperancy_17x18.png"}',
        button_width: 86,
        button_height: 18,
        button_text: '<span class="button">批量上传</span>',
        button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; font-weight: bold; color: #3F3D3E; } .buttonSmall { font-size: 10pt; }',
        button_text_top_padding: 0,
        button_text_left_padding: 18,
        button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
        button_cursor: SWFUpload.CURSOR.HAND,

        // The event handler functions are defined in handlers.js
        file_queue_error_handler: fileQueueError,
        file_dialog_complete_handler: fileDialogComplete,
        upload_progress_handler: uploadProgress,
        upload_error_handler: uploadError,
        upload_success_handler: uploadSuccess,
        upload_complete_handler: uploadComplete,
        button_placeholder_id: "spanButtonPlaceholder",
        file_queued_handler : fileQueued
    });
});

function add_uploadedfile(file_data)
{
		  var file_arr=new Array();
		  file_arr.push(new Array(file_data.file_name,file_data.file_id));
		  $("#divSwfuploadContainer").append('<input type="hidden" name="upfiles[]" value="'+file_data.file_id+'" />');
		  		  $("div.uppic_con").append('<a href="download.php?id='+file_data.file_id+'"><img src="'+file_data.file_path+'" width="130" height="80" alt="图片"/></a><a class="pic_del" href="index.php? app=comupload&act=delete&id='+file_data.file_id+'" onClick="return confirm('+"{$lang.confirm_del_file}"+')" title="{$lang.delete}">&nbsp;</a>');


}
</script>
    </head>
    <body>
        <div class="sub-body">
<div class="tab-frame" style="width:900px;">
    <div class="tab-title-1"><span>色卡库信息</span></div>
    <form id="color_form" method="post" enctype="multipart/form-data">
        <table width="100%" cellspacing="0" cellpadding="0" align="left" class="tab-display">
            <tbody><tr>
                    <th align="center" width="20%">更新日期</th>
                    <td align="left">
                    	<input type="text" class="input-1" name="update_time" id="order_create_date"  readonly="readonly" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$this_time|date}" />
                   </td>
                   </tr>
                 <tr>
                    <th align="center">布行/档口</th>
                    <td align="left">
                    	<select select_input="select_input" style=" width:150px;" name="fabric_shop_id" id="fabric_shop_id" class="input-3" val="" onblur="javascript:check_fi();">
		  	<option value="">请选择布行/档口</option>
		  	<!--{foreach from=$fabricshop_list item=fabric_shop}-->
			<option value="{$fabric_shop.fabric_shop_id}" {if $fabric_shop.user_id==$user.user_id}selected{/if}>{$fabric_shop.fabric_shop_name|escape}</option>
			<!--{/foreach}-->
						</select>
                    </td>
                 </tr>
                 <tr>
                    <th align="center">品名/货号</th>
                    <td align="left"><input class="input-1" type="text" name="item" id="item" onblur="javascript:check_fi();"/></td>
               		<label></label>
                </tr>
                 <tr>
                    <th align="center">价&nbsp;&nbsp;&nbsp;&nbsp;格</th>
                    <td align="left">
                        <input type="text" class="input-1" name="price" id="order_sn" />
                    </td>
                  </tr>
                  <tr>
                    <th align="center">幅&nbsp;&nbsp;&nbsp;&nbsp;宽</th>
                    <td align="left">
                        <input type="text" class="input-1" name="width" id="order_sn" />
                    </td>
                </tr>
                <tr>
                    <th align="center">面料特征</th>
                    <td align="left">
                        <div id="fabric_assign">
						<!-- {foreach from=$color_char_list item=chars name=cl} -->
							<input name="color_char_id[]" type="checkbox" value="{$chars.cf_id}" />&nbsp;{$chars.cf_characteristics}&nbsp;
						<!-- {/foreach} -->
						</div>
                    </td>
                </tr>
                <tr>
                    <th align="center">颜色属性</th>
                    <td align="left">
                        <div id="color_assign">
						<!-- {foreach from=$color_attr_list item=attrs name=ca} -->
							<input name="color_attr_id[]" type="checkbox" value="{$attrs.cs_id}" />&nbsp;{$attrs.cs_name}&nbsp;
						<!-- {/foreach} -->
						</div>
                    </td>
                </tr>
                <tr>
                    <th align="center">照片</th>
                    <td align="left">
                    <input type="hidden" class="input-1"  name="file_required" />
                     <div  class="uppic_con">
                     </div>
                    <div class="upload_wrap" >
<ul>
	<li class="btn1">
	<div id="divSwfuploadContainer">
	<div id="divButtonContainer"><span id="spanButtonPlaceholder"></span>
	</div>
	</div>
	</li>
</ul>
<br />
        <div id="goods_upload_progress"></div>
</div>
                     
                    </td>
                </tr>
                <input type="hidden" name="app" value="colorcard" />
                <input type="hidden" name="act" value="add" />
                 <tr>
                <td colspan="6">
                        <input type="submit" value="添加" id="submit" class="btn-2" />
                        <input type="button" value="返回" class="btn-2" onclick="history.back();" />
                    </td></tr>
            </tbody></table>
    </form>
</div>

           
        </div>
        <div id="remsg"></div>
<script language="JavaScript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
    </body>
</html>